package com.collect.tanzania.zhiAdater.zhiLevelDetail;

import android.view.View;
import android.widget.ImageView;

import com.chad.library.adapter.base.BaseQuickAdapter;
import com.chad.library.adapter.base.BaseViewHolder;
import com.collect.tanzania.R;
import com.collect.tanzania.zhiBean.zhiReceive.ZHIRPerformanceDayDetailEntity;

public class ZHILevelDetailAdjuster extends BaseQuickAdapter<ZHIRPerformanceDayDetailEntity, BaseViewHolder> {

    public ZHILevelDetailAdjuster() {
        super(R.layout.item_level_detail_list, null);
    }

    private OnZHILevelDetailAdjuster mOnZHILevelDetailAdjuster;

    @Override
    protected void convert(BaseViewHolder helper, ZHIRPerformanceDayDetailEntity item) {
        helper.setText(R.id.tv_detail_date, item.getAssignDate());
        helper.setText(R.id.tv_detail_case_num, item.isLevelB3() ? item.getAssignAmountFormatWithoutFinceUnit() : item.getAssignNum());
        helper.setText(R.id.tv_detail_collected_num, item.isLevelB3() ? item.getRepayAmountFormatWithoutFinceUnit() : item.getRepayNum());
        helper.setText(R.id.tv_detail_collected_rate, item.isLevelB3() ? item.getRepayAmountRate() : item.getRepayNumRate());
        helper.setText(R.id.tv_detail_bonus, item.getBonus());

        ImageView iv_detail_ext_img = helper.getView(R.id.iv_detail_ext_img);
        if (item.isGreenCard() || item.isYellowCard()) {
            iv_detail_ext_img.setVisibility(View.VISIBLE);

            if (item.isYellowCard()) {
                iv_detail_ext_img.setImageResource(R.drawable.ic_136);
            } else {
                iv_detail_ext_img.setImageResource(R.drawable.ic_137);
            }
        } else {
            iv_detail_ext_img.setVisibility(View.GONE);
        }

        helper.getView(R.id.ll_content_bg).setOnClickListener(v -> {
            if (mOnZHILevelDetailAdjuster != null) {
                mOnZHILevelDetailAdjuster.OnItemClick(item);
            }
        });
    }

    public void setOnZHILevelDetailAdjusterItemClickListener(OnZHILevelDetailAdjuster listener) {
        this.mOnZHILevelDetailAdjuster = listener;
    }

    public interface OnZHILevelDetailAdjuster {
        void OnItemClick(ZHIRPerformanceDayDetailEntity zhirPerformanceDayDetailEntity);
    }
}
